package A1_贪心算法;

public class LC_376摆动序列 {
    public int wiggleMaxLength(int[] nums) {
        if(nums.length==1)
            return 1;
        int result=1;
        int prediff=0,curdiff=0;
        for(int i=0;i<nums.length;i++){
            if(i<nums.length-1) {
                curdiff = nums[i + 1] - nums[i];
                if(prediff>=0 && curdiff<0 || prediff<=0 && curdiff>0){
                    result++;
                    prediff=curdiff;
                }
            }
        }
        return result;
    }
}
